<html>
<head><meta charset="utf-8"><title>how to handle `Debug` · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html">how to handle `Debug`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="191523973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191523973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191523973">(Mar 23 2020 at 19:27)</a>:</h4>
<p>So <span class="user-mention" data-user-id="116458">@Charles Lew</span> I'm going to break this out into a separate Zulip topic.</p>



<a name="191524003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191524003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191524003">(Mar 23 2020 at 19:27)</a>:</h4>
<p>I wonder if at this point we should just stop using <code>Debug</code></p>



<a name="191524076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191524076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191524076">(Mar 23 2020 at 19:28)</a>:</h4>
<p>Rather than lean so heavily on TLS</p>



<a name="191524108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191524108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191524108">(Mar 23 2020 at 19:28)</a>:</h4>
<p>Specifically, would definitely add a <code>DebugWithInterner</code> trait</p>



<a name="191524120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191524120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191524120">(Mar 23 2020 at 19:28)</a>:</h4>
<p>and write out own derive for it</p>



<a name="191524158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191524158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191524158">(Mar 23 2020 at 19:28)</a>:</h4>
<p>and then modify code from doing <code>debug!("{:?}", foo)</code> to <code>debug!("{:?}", foo.debug(interner))</code></p>



<a name="191524261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191524261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191524261">(Mar 23 2020 at 19:29)</a>:</h4>
<p>That said, this would definitely be something we have to "negotiate" eventually with rustc, which uses TLS extensively here.</p>



<a name="191524281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191524281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191524281">(Mar 23 2020 at 19:29)</a>:</h4>
<p>Probably the code you have in the PR is a good start for now, and this can be something we revisit over time</p>



<a name="191524631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191524631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191524631">(Mar 23 2020 at 19:32)</a>:</h4>
<p>I personally think the debug(interner) style doesn't work too well, though maybe in something like rustc it would -- the problem is that you need special impls for every type in the world (Vec, HashMap, etc.). But maybe that's a relatively low cost to pay...</p>



<a name="191524711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191524711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191524711">(Mar 23 2020 at 19:32)</a>:</h4>
<p>(in an application like rustc at least where we have "total control" in some sense over our data structures etc)</p>



<a name="191525421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191525421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191525421">(Mar 23 2020 at 19:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60/near/191524631" title="#narrow/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60/near/191524631">said</a>:</p>
<blockquote>
<p>I personally think the debug(interner) style doesn't work too well, though maybe in something like rustc it would -- the problem is that you need special impls for every type in the world (Vec, HashMap, etc.). But maybe that's a relatively low cost to pay...</p>
</blockquote>
<p>yeah, that's part of it</p>



<a name="191525436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191525436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191525436">(Mar 23 2020 at 19:38)</a>:</h4>
<p>although I don't think that's too bad personally</p>



<a name="191525467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191525467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191525467">(Mar 23 2020 at 19:39)</a>:</h4>
<p>it's not too bad, certainly</p>



<a name="191525487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191525487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191525487">(Mar 23 2020 at 19:39)</a>:</h4>
<p>in Lark I was exploring a different option</p>



<a name="191525522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191525522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191525522">(Mar 23 2020 at 19:39)</a>:</h4>
<p>where you had a <code>debug_with</code> trait but, depending on what context you gave, you might get more or less detail or different output</p>



<a name="191525536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191525536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191525536">(Mar 23 2020 at 19:39)</a>:</h4>
<p>that was based on specialization</p>



<a name="191525609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191525609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191525609">(Mar 23 2020 at 19:40)</a>:</h4>
<p>might've been overkill; I wanted a way to have e.g. inference variables that were bound be automatically resolved and things like that</p>



<a name="191525618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191525618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191525618">(Mar 23 2020 at 19:40)</a>:</h4>
<p>one note is that if you do go down the debug(interner) route it seems like it might be good to have something like <code>format_with!(interner, "...{:?} as {:?} with {:?}.", foo, bar, baz)</code></p>



<a name="191525630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191525630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191525630">(Mar 23 2020 at 19:40)</a>:</h4>
<p>it's based on the observation that, depending on context, I sometimes want different "level of detail" in the output</p>



<a name="191525735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191525735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191525735">(Mar 23 2020 at 19:41)</a>:</h4>
<p>(One crazy idea is that we can technically just embed this into std; the <code>Formatter</code> type already caries state and could fairly easily get a dyn Any in there, I suspect. Though that might conflict with interners (which are frequently non-static, I suspect)</p>



<a name="191586669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191586669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191586669">(Mar 24 2020 at 09:54)</a>:</h4>
<p>ok~ If modifications to the PR are needed, or there's something more that needs to be done, just leave me a message :)</p>



<a name="191664507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191664507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191664507">(Mar 24 2020 at 20:00)</a>:</h4>
<p><span class="user-mention" data-user-id="116458">@Charles Lew</span> I think it can be merged "as is" for now</p>



<a name="191664509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/how%20to%20handle%20%60Debug%60/near/191664509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/how.20to.20handle.20.60Debug.60.html#191664509">(Mar 24 2020 at 20:00)</a>:</h4>
<p>will do</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>